package org.kernely.core;

import java.util.Dictionary;

import org.kernely.core.service.KernelySettingsService;

public class KernelySettingsServiceImpl implements KernelySettingsService {

	// private static PreferencesService preferencesService;

	/**
	 * Create new properties for the bundle bundleName using Apache Preferences
	 * Service
	 * 
	 * @param bundleName
	 *            : name of the concerned bundle
	 * @param propertiesDictionary
	 *            : Dictionary which contains bundle's properties (String key,
	 *            String value)
	 */
	@SuppressWarnings("unchecked")
	public void newProperties(String bundleName, Dictionary propertiesDictionary) {
		// // Find, or create if not exists the bundleName node
		// Preferences pref =
		// preferencesService.getSystemPreferences().node(bundleName);
		// // For each element of the dictionnary, we create an entry into the
		// preferences object
		// Enumeration keys = propertiesDictionary.keys();
		// while(keys.hasMoreElements()){
		// String key = (String)keys.nextElement();
		// String value = (String)propertiesDictionary.get(key);
		// pref.put(key, value);
		// }
		// try {
		// pref.flush();
		// } catch (BackingStoreException e) {
		// e.printStackTrace();
		// }
	}

	/**
	 * This method get a property from the properties file of the bundle.
	 * 
	 * @param bundleName
	 *            The name of the bundle (is used to determines the properties
	 *            file name).
	 **/
	public String getProperty(String bundleName, String key) {
		// Preferences pref = preferencesService.getSystemPreferences();
		// String prop;
		// try {
		// if(pref.nodeExists(bundleName)){
		// prop = pref.node(bundleName).get(key,
		// "This property doesn't exist for this bundle");
		// }
		// else{
		// prop = "No value.";
		// }
		// return prop;
		// } catch (BackingStoreException e) {
		// e.printStackTrace();
		// return null;
		// }
		
		return "";

	}

	// /**
	// * Gets the preferences service, used for settings.
	// * @return the preferencesService
	// */
	// public static PreferencesService getPreferencesService() {
	// return preferencesService;
	// }
	//
	// /**
	// * Sets the preferences services.
	// * @param preferencesService the preferencesService to set
	// */
	// public static void setPreferencesService(PreferencesService
	// preferencesService) {
	// KernelySettingsServiceImpl.preferencesService = preferencesService;
	// }
}
